

import 'package:floor/floor.dart';

import '../entity/AttributeBean.dart';

@dao
abstract class AttributeDao {

  @Query('DELETE FROM AttributeBean')
  Future<void> deleteAll();

  @Query('DELETE FROM AttributeBean WHERE id = :id')
  Future<void> deleteById(int id);

  @Query('SELECT * FROM AttributeBean')
  Future<List<AttributeBean>> findAll();

  @Query('SELECT * FROM AttributeBean WHERE attributeCode IN (:codes)')
  Future<List<AttributeBean>> findInCodesList(List<String> codes);

  @Query('SELECT * FROM AttributeBean WHERE parentCode = :value')
  Future<List<AttributeBean>> findByParentCode(String value);

  @Query('SELECT * FROM AttributeBean WHERE attributeLevel = :value')
  Future<List<AttributeBean>> findByAttributeLevel(String value);


  @Query('SELECT * FROM AttributeBean WHERE id = :id')
  Future<AttributeBean?> findById(int id);

  @insert
  Future<void> insertOne(AttributeBean person);

  @Update(onConflict: OnConflictStrategy.replace)
  Future<int> updateOne(AttributeBean bean);
}